import { User, UserProfile } from '@/types/data'
import { ProfileAction } from '@/types/store'
type ProfileState = {
  user: User,
  userProfile :UserProfile
}

const initialState = {
  user: {},
  userProfile: {}
} as ProfileState

const profile = (state = initialState, action: ProfileAction): ProfileState => {
  if (action.type === 'profile/getUser') {
    return { ...state, user: action.payload }
  } else if (action.type === 'profile/getUserProfile') {
    return { ...state, userProfile: action.payload }
  } else {
    return state
  }
}

export default profile
